#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

const ll N = 1e6 + 10, INF = 0x3f3f3f3f;

ll n;
ll a[N];
map <ll, pair<int, int>> hs;

int cnt_len(int x)
{
    int res = 0;
    while (x) res++, x /= 10;
    return res;
}

void solve()
{
    cin >> n;
    for (ll i = 1;i <= n;i++) {
        cin >> a[i];
        if (cnt_len(a[i]) % 2 == 1) {
            hs[a[i] % 11].first++;
        } else {
            hs[a[i] % 11].second++;
        }
    }

    int ans = 0;
    for (int i = 1;i <= 10;i++) {
        //奇数长度
        ans += hs[i].first * (hs[i].first + hs[i].second);
        //偶数长度
        ans += hs[i].second * (hs[11 - i].first + hs[11 - i].second);
    }
    cout << ans;
}

signed main()
{
    //ios::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll T = 1;
    //cin>>T;
    for (ll i = 1;i <= T;i++) {
        solve();
    }
}